package com.KKd.service;

import com.KKd.mapper.UserMapper;
import com.KKd.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author 14587
 * @date 2020/11/10 19:45
 */
@Service
@Resource
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public boolean logIn(String username, String password) {
        Map<String, Object> map = userMapper.showUser();
        String name= (String) map.get("username");
        String pwd= (String) map.get("password");
        //TODO: 使用正规验证
        if (name.equals(username)&&pwd.equals(password)){
            return true;
        }
        return false;
    }

    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    public Map<String,Object> showUser() {
        return userMapper.showUser();
    }
}
